package mid

import "sort"

func CountWays(nums []int) int {
	n := len(nums)
	res := 0
	sort.Ints(nums)
	for i := 0; i <= n; i++ {
		if i > 0 && nums[i-1] >= i {
			continue
		}
		if i < n && nums[i] <= i {
			continue
		}
		res++
	}
	return res
}
